package com.yanze.schoolinformation.view.information.gank;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;

import com.yanze.schoolinformation.R;
import com.yanze.schoolinformation.adapter.vp.MyFragmentPagerAdapter;
import com.yanze.schoolinformation.base.BaseActivity;
import com.yanze.schoolinformation.databinding.ActivityGankBinding;

import java.util.ArrayList;
import java.util.List;

public class GankActivity extends BaseActivity<ActivityGankBinding> {
    List<String> mTitleList = new ArrayList<>();
    List<Fragment> mFragments = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_gank);
        setTitle("干货");

        initFragmentList();

        MyFragmentPagerAdapter myAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager(), mFragments, mTitleList);
        bindingView.vpGank.setAdapter(myAdapter);
        //左右预加载页面的个数
        bindingView.vpGank.setOffscreenPageLimit(3);
        myAdapter.notifyDataSetChanged();
        bindingView.tabGank.setTabMode(TabLayout.MODE_FIXED);
        bindingView.tabGank.setupWithViewPager(bindingView.vpGank);
        showContentView();
    }

    private void initFragmentList() {
        mTitleList.add("干货定制");
        mTitleList.add("玩安卓");
        mTitleList.add("大安卓");
        mFragments.add(new CustomFragment());
        mFragments.add(new WanAndroidFragment());
        mFragments.add(new BigAndroidFragment());
    }

    /**
     * 入口
     */
    public static void start(Context context) {
        context.startActivity(new Intent(context, GankActivity.class));
    }
}
